﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace TD.TheGame
{
    public class CastleSideTower : CastleSprite
    {
        CastleShooter castleShooter;
        public CastleSideTower(Game game, Vector2 position, bool active, int maxLoopTime, SpriteEnumState state, SpriteEnumState side)
            : base(game, position, active, maxLoopTime, state)
        {
            castleShooter = new CastleShooter(game, new Vector2(position.X + 35, position.Y - 55), false, 300, SpriteEnumState.Shoot, side);
            Arrows = castleShooter.CastleArrows;
        }

        public override void Update(GameTime gameTime)
        {
            if (oldUpgradeState != upgradeState)
            {
                if (upgradeState == SpriteEnumState.Shoot)
                {
                    castleShooter.Active = true;
                }
                else
                {
                    castleShooter.Active = false;
                }
            }
            oldUpgradeState = upgradeState;
            castleShooter.Update(gameTime);
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            castleShooter.Draw(gameTime);
            base.Draw(gameTime);
        }

        public override void Reset()
        {
            throw new System.NotImplementedException();
        }

        //upgrade
        public override void Upgrade(SpriteEnumState state)
        {
            if (state == SpriteEnumState.Shoot)
            {
                State = state;
            }
        }

        //Get the name of the current string by looking at the state of the sprite
        public override string GetName()
        {
            string name = "";
            if (State == SpriteEnumState.Past)
            {
                name = "toren1";
            }
            if (State == SpriteEnumState.Normal)
            {
                name = "toren2";
            }
            if (State == SpriteEnumState.Future)
            {
                name = "toren3";
            }
            return name;
        }
    }
}
